package socket;

import java.io.*;
import java.net.Socket;

public class Pengirim {
	private PrintWriter output;
	private Socket socket;
	public Pengirim(String alamatTujuan, Integer portTujuan) {
		try{
			socket = new Socket(alamatTujuan,portTujuan);
			output = new PrintWriter(socket.getOutputStream());
		}
		catch(Exception e){
			e.printStackTrace();
		}
	}
	
	public void kirim(String pesan){
		output.println(pesan);
		output.flush();
	}
	
	public void disconnect(){
		output.close();
		try {
			socket.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	
}
